home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / PredatorPrey / FlightSim / offScrPort.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-22  |  1.1 KB  |  52 lines  |  [TEXT/KAHL]

  1. #include "flight.h"
  2.  
  3. extern    WindowPtr        theWind;    /*the main window*/
  4.  
  5. BitMap    oldMap;
  6. GrafPort    offPort;
  7.  
  8.  
  9. SetBack()
  10. {
  11.     SetPort(&offPort);
  12. }
  13.  
  14. MkPort(theWindow)
  15. WindowPtr    theWindow;
  16. {
  17.     Rect    windRect;
  18.     QDPtr    newSpace;
  19.     int        rwBytes;
  20.  
  21.     windRect = theWindow->portRect;
  22.     windRect.bottom = windRect.bottom - windRect.top;
  23.     windRect.top = 0;
  24.     windRect.right = windRect.right - windRect.left;
  25.     windRect.left = 0;
  26.  
  27.     OpenPort(&offPort);
  28.     offPort.portRect = windRect;
  29.     offPort.portBits.bounds = windRect;
  30.     SetRectRgn(offPort.visRgn, 0, 0, windRect.right, windRect.bottom);
  31.     SetRectRgn(offPort.clipRgn, 0, 0, windRect.right, windRect.bottom);
  32.  
  33.     rwBytes = ((windRect.right + 15) / 16) * 2;
  34.     newSpace = NewPtr((long)rwBytes * windRect.bottom);
  35.     if (MemErr)
  36.         return;
  37.  
  38.     offPort.portBits.rowBytes = rwBytes;
  39.     offPort.portBits.baseAddr = newSpace;
  40.     SetPort(&offPort);
  41.     EraseRect(&offPort.portRect);
  42. }
  43.  
  44. GetWind(theWindow)
  45. WindowPtr    theWindow;
  46. {
  47.     CopyBits(&offPort.portBits, &theWindow->portBits,
  48.             &offPort.portRect, &theWindow->portRect,
  49.             srcCopy, 0L);
  50. }
  51. /*    rowBytes = ((width + 15) / 16) * 2;*/
  52.